package edu.neusoft.android.yuejian14.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jude.rollviewpager.RollPagerView;
import com.squareup.picasso.Picasso;

import edu.neusoft.android.yuejian14.Listener.RetrofitListener;
import edu.neusoft.android.yuejian14.R;
import edu.neusoft.android.yuejian14.javabean.Club;
import edu.neusoft.android.yuejian14.model.ClubModel;

import static edu.neusoft.android.yuejian14.Const_Pic.BASE_URL;

public class ClubIntroActivity extends BaseActivity implements View.OnClickListener,RetrofitListener {
        private RollPagerView rollPV = null;
        private TextView name,intro,phone,addess,time,coachname,coachintro,club_course,club_video;
        private static ImageView clubpic,coachphoto;
        private int clubid;

    @Override
    void initViews() {
        setLayout(R.layout.club_intro);
        name = (TextView) findViewById(R.id.c_name);
        intro = (TextView) findViewById(R.id.c_intro);
        phone = (TextView) findViewById(R.id.c_phone);
        addess = (TextView) findViewById(R.id.c_address);
        time = (TextView) findViewById(R.id.c_time);
        coachname = (TextView) findViewById(R.id.c_coachname);
        coachintro = (TextView) findViewById(R.id.c_coachintro);
        clubpic = (ImageView) findViewById(R.id.c_pic);
        coachphoto = (ImageView) findViewById(R.id.c_photo);
        club_course =(TextView) findViewById(R.id.club_class);
        club_course.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View view) {
                Intent intent =new Intent(ClubIntroActivity.this,CourseListActivity.class);
                Bundle bundle= getIntent().getExtras();
                clubid=bundle.getInt("clubid");
                intent.putExtra("clubid",clubid);
                startActivity(intent);

            }
        });

        club_video =(TextView) findViewById(R.id.club_video);
        club_video.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                Intent intent =new Intent(ClubIntroActivity.this,VideoListActivity.class);
                Bundle bundle= getIntent().getExtras();
                clubid=bundle.getInt("clubid");
                intent.putExtra("clubid",clubid);
                startActivity(intent);

            }
        });

    }

    @Override
    View initViews(View view) {
        return null;
    }

    @Override
    void initEvents() {

    }

    @Override
    void initData() {
        Intent intent=getIntent();
        Bundle bundle=intent.getExtras();
        clubid=bundle.getInt("clubid");

        ClubModel clubModel = new ClubModel();
        clubModel.getClubById(String.valueOf(clubid),this);
    }

    @Override
    public void onSuccess(Object object, int flag) {
                   Club club= (Club) object;
                   name.setText(club.getClubname());
                    intro.setText(club.getClubintro());
                    phone.setText(club.getClubphone());
                    addess.setText(club.getClubaddress());
                    time.setText(club.getClubtime());
                    coachname.setText(club.getCoachname());
                    coachintro.setText(club.getCoachintro());
                    String clubpic = BASE_URL  + club.getClubpic();
                    if (!"".equals(club.getClubpic()))
                        Picasso.with(ClubIntroActivity.this).load(clubpic).error(R.drawable.no_pic).into(ClubIntroActivity.clubpic);
                    String coachphoto = BASE_URL  + club.getCoachphoto();
                    if (!"".equals(club.getCoachphoto()))
                        Picasso.with(ClubIntroActivity.this).load(coachphoto).error(R.drawable.no_pic).into(ClubIntroActivity.coachphoto);

    }

    @Override
    public void onFail() {

    }

    @Override
    public void onClick(View view) {

    }

    }
